package evostar.service;

import evostar.dao.GoodsDAO;
import evostar.model.SeckillGoods;
import evostar.VO.GoodsVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class GoodsService {
    @Autowired
    private GoodsDAO goodsDAO;
    public static final String GoodList = "goodsList";
    public static final String GoodDetail = "goodsDetail_";//goodsDetail_商品id
    public static final String GoodStock = "goodStock_"; //goodStock_商品id
    public static final String GoodsOver = "goodsOver_";//goodsOver_商品id

    public List<GoodsVO> listGoodsVO() {
        return goodsDAO.listGoodsVO();
    }

    public GoodsVO getGoodsByGoodsId(int goodsId) {
        return goodsDAO.getGoodsByGoodsId(goodsId);
    }

    //减库存
    public int reduceStock(GoodsVO goods) {
        SeckillGoods g = new SeckillGoods();
        g.setGoodsId(goods.getId());
        return goodsDAO.reduceStock(g);
    }
}
